<?php
require_once(dirname(dirname(__FILE__)) . '/app.php');
header('Content-Type: text/xml; charset=UTF-8;');

$daytime = strtotime(date('Y-m-d'));
$condition = array( 
		"begin_time <= $daytime",
		"end_time > $daytime",     
	/*  "city_id= 1 ", //去掉本段文字前面的 / × 和后面的 * /  符号将1换成你要显示的城市代码，就可以建立多个城市的API接口，放到不同的城市文件夹，就可以达到拉手的效果*/ 
		);
$teams = DB::LimitQuery('team', array(
			'condition' => $condition,
			));

$si = array(
		'sitename' => $INI['system']['sitename'],
		'wwwprefix' => $INI['system']['wwwprefix'],
		'imgprefix' => $INI['system']['imgprefix'],
		);

foreach($teams AS $one) {
	$city = Table::Fetch('category', $one['city_id']);
	$group = Table::Fetch('category', $one['group_id']);	
	
	$item = array();
	$item['cityid'] = $one['city_id'];
	($item['cityname'] = $city['name']) || ($item['cityname'] = '全国');
	
	$partner = Table::Fetch('partner', $one['partner_id']);
	$o = array();
	$o['goods_title'] = $one['title'];
	$o['goods_rules'] = $one['summary'];
	$o['goods_value'] = $one['market_price'];
	$o['goods_price'] = $one['team_price'];
	if ( $one['market_price'] > 0 ) {
		$o['goods_rebate'] = moneyit(10*$one['team_price']/$one['market_price']);
	} else {
		$o['goods_rebate'] = '0';
	}
	$o['goods_start_time'] = $one['begin_time'];
	$o['goods_deadline'] = $one['end_time'];
	$o['goods_left_second'] = $one['end_time']-strtotime(date("Y-m-d H:i:s"));
	$o['goods_expire'] = $one['expire_time'];
	$o['goods_convey_fee'] = $one['fare'];
	$o['goods_description'] = '<p style="line-height: 200%"><b>【详情】</b>
'.$one['detail'].'<br><br>
<br>

<p style="font-size:18px;font-family:Arial, Helvetica, sans-serif;line-height: 200%"><b>温馨提示</b></p>
'.$one['notice'] ;
	$o['goods_bought'] =  abs(intval($one['now_number']));
	$o['goods_min_bought'] = $one['min_number'];
	$o['goods_max_bought'] = $one['max_number'];
	$o['goods_sp_name'] = $partner['title'];//商家名称 

	$o['goods_sp_url'] =  $si['imgprefix']  .'/static/' . $one['image']; //商品小图片路径 

	$o['goods_image_url'] =  $si['imgprefix']  .'/static/' . $one['image']; //商品大图 

	$o['goods_site_url'] = $si['wwwprefix'] . "/team.php?id={$one['id']}";  //商品网址 

	$o['goods_phone'] = $partner['phone']; //联系电话 
	$item['goods'] = $o;

}

Output::XmlBaidu($item);
